function api (url) {
  return fetch(url).then(d => d.json())
}

function getDetail (id) {
  var url = 'https://news-at.zhihu.com/api/4/news/' + id
  return api(url)
}

function getList () {
  var url = 'https://news-at.zhihu.com/api/4/news/latest'
  return api(url)
}

function query () {
  getList().then(d => {
    if (d.stories.length) {
      getDetail(d.stories[0].id).then(rs => {
        console.info(rs)
      })
    }
  })
}

async function asyncQuery () {
  console.info('开始asyncQuery...')
  const rs = await getList()
  console.info('asyncQuery 结束')
  if (rs.stories.length) {
    const detail = await getDetail(rs.stories[0].id)
    console.info(detail)
  }
}
query()
asyncQuery()
